//
//  ZDShopCarBar.m
//  ZDPension
//
//  Created by 刘甲奇 on 2017/6/16.
//  Copyright © 2017年 maker. All rights reserved.
//

#import "ZDShopCarBar.h"

@interface ZDShopCarBar()
@property (weak, nonatomic) IBOutlet UIButton *selectAllButton;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *buyButton;

/**
 全选状态
 */
@property (nonatomic, assign) BOOL allSelecting;
/**
 <#Description#>
 */
@property(nonatomic,strong)shopCarBarOpertionBlock block;

@end

@implementation ZDShopCarBar

- (IBAction)selectAllClick:(UIButton *)sender
{
    [self setAllSelectUI];
    self.allSelecting = !self.allSelecting;
    _block(1,_allSelecting);
}

- (IBAction)buyClick:(UIButton *)sender
{
    _block(2,NO);
}
- (void)shopCarBarOpertion:(shopCarBarOpertionBlock)block
{
    _block = block;
}
- (void)setTotalPrice:(NSString *)totalPrice goodsNumber:(NSString *)goodsNumber
{
    self.priceLabel.text = totalPrice;
    [self.buyButton setTitle:[NSString stringWithFormat:@"立即订购(%@)",goodsNumber] forState:0];
}

- (void)setAllSelecting:(BOOL)allSelecting
{
    _allSelecting = allSelecting;
    [self setAllSelectUI];
}

#pragma mark- privateMethod
- (void)setAllSelectUI
{
    UIImage *image = _allSelecting ? [UIImage imageNamed:@"selected"] : [UIImage imageNamed:@"unSelected"];
    [self.selectAllButton setImage:image forState:0];
}

@end
